<template>
	<view class="content">
		<z-paging ref="paging" v-model="dataList" :default-page-size="row" @onRefresh="onRefresh" @query="getList"
			auto-show-system-loading auto-show-back-to-top>
			<view class="" style="padding: 20rpx;">
				<view class="list-box" @click="goto(item)" v-for="(item,index) in dataList" :key="index">
					<view class="title-box">
						产品名称:{{item.goodsName}}
					</view>
					<view class="info-box">
						<view class="info-item" v-if="item.orderCount">
							<view class="info-item-title">
								订单数量
							</view>
							<view class="info-item-text">
								{{item.orderCount}}
							</view>
						</view>
						<view class="info-item" v-if="item.lockCount">
							<view class="info-item-title">
								锁定数量
							</view>
							<view class="info-item-text">
								{{item.lockCount}}
							</view>
						</view>
						<view class="info-item" v-if="item.pleaseBuyCount">
							<view class="info-item-title">
								请购数量
							</view>
							<view class="info-item-text">
								{{item.pleaseBuyCount}}
							</view>
						</view>
						<view class="info-item" v-if="item.unit">
							<view class="info-item-title">
								计量单位
							</view>
							<view class="info-item-text">
								{{item.unit}}
							</view>
						</view>
					</view>
					<view class="text-box" v-if="item.nos">
						订单编号：{{item.nos}}
					</view>
					<view class="text-box" v-if="item.goodsCode">
						产品编码：{{item.goodsCode}}
					</view>
					<view class="text-box" v-if="item.goodModel">
						产品型号：{{item.goodModel}}
					</view>
				</view>
			</view>
		</z-paging>
<!-- 		<view class="bottom-box">
			<view class="bnt" @click="deitBnt(item,1)">
				同意
			</view>
			<view class="bnt" @click="deitBnt(item,2)">
				驳回
			</view>
		</view> -->
	</view>
</template>

<script>
	import * as index from '@/api/index.js'
	export default {
		data() {
			return {
				id: '',
				row: 10,
				tabList: [],
				tableIndex: 1, //当前选择
				dataList: [],
			}
		},
		onLoad(e) {
			this.id = e.id
		},
		methods: {
			jianting() {
				var pages = getCurrentPages();
				console.log(pages.length);
				var Page = pages[pages.length - 1]; //当前页
				console.log(pages[pages.length - 1].route); //输出当前路由
				var prevPage = pages[pages.length - 2];
				console.log(pages[pages.length - 2].route); //输出上一个页面的路由
				if (pages[pages.length - 2].route ==
					'pagesA/orderAdmin/procurementAudit/index') { //确定要返回到相应页面，在触发
					prevPage.$vm.reload()
				}
			},
			deitBnt(e,stutas) {
				uni.showModal({
					title: '提示',
					content: stutas == 2 ? '确定审核不通过吗？' : '确定审核通过？',
					success :(res)=> {
						if (res.confirm) {
							if(stutas == 2) {
								index.lvDoBuyReject({id:this.id}).then(res=>{
									uni.navigateBack(-1);
									this.jianting();
								})
							} else {
								index.goodsSaledoSubSuccess({id:this.id}).then(res=>{
									uni.navigateBack(-1);
									this.jianting();
								})
							}
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			// 当页面滚动到底部事件被触发
			onReachBottom() {
				// 通知z-paging滚动到底部了，z-paging会进行相应的处理，例如加载更多数据
				this.$refs.paging.pageReachBottom();
			},
			// 下拉刷新被触发
			onRefresh() {
				// 告知z-paging下拉刷新结束，这样才可以开始下一次的下拉刷新
				setTimeout(() => {
					this.$tools.toast('刷新成功～')
				}, 500)
			},
			// @query所绑定的方法不要自己调用！！需要刷新列表数据时，只需要调用this.$refs.paging.reload()即可
			getList(pageNum, pageSize) {
				// this.$refs.paging.complete(false);
				index.goodsSaledoList({
					pageNum,
					pageSize,
					mainId: this.id,
					isBuy:'1',
					isdo:'0'
				}).then(res => {
					console.log(res, '这是什么')
					this.$refs.paging.complete(res.rows);
				})
			}
		}

	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-left: 20rpx;
		padding-right: 20rpx;

		.list-box {
			padding-left: 20rpx;
			padding-right: 20rpx;
			margin-top: 20rpx;
			border-radius: 8rpx;
			background: #FFF;

			.top-box {
				display: flex;
				align-items: center;
				padding: 20rpx 0rpx;

				.tiem-box {
					color: #999;
					font-size: 24rpx;
				}

				.status-box {
					margin-left: auto;
					display: flex;
					align-items: center;

					.item-box {
						padding: 4rpx 12rpx;
						height: 42rpx;
						border-radius: 10rpx;
						background: #F5F7FB;
						color: #8295BC;
						font-size: 24rpx;
					}
				}
			}

			.xian {
				width: 662rpx;
				border-bottom: 1px solid #EAEAEA;
			}

			.title-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				color: #333;
				font-size: 28rpx;
				font-weight: bold;
			}

			.info-box {
				display: flex;
				align-items: center;
				border-radius: 8rpx;
				background: #F5F7FB;
				padding-top: 10rpx;
				padding-bottom: 10rpx;

				.info-item {
					flex: 1;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.info-item-title {
						color: #999;
						font-size: 24rpx;
					}

					.info-item-text {
						margin-top: 8rpx;
						color: #333;
						font-size: 28rpx;
						font-weight: bold;
					}
				}
			}

			.text-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				color: #999;
				font-size: 24rpx;
			}

			.bnt-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;

				.bnt-big-box {
					display: flex;
					justify-content: flex-end;
					align-items: center;

					.bnt {
						margin-right: 20rpx;
						display: flex;
						align-items: center;
						border-radius: 10rpx;
						background: #F5F7FB;
						padding: 15rpx 20rpx 15rpx 20rpx;
						color: #4D8987;
						font-size: 24rpx;
					}
				}
			}
			
		}
		.bottom-box {
			position: fixed;
			bottom: 0;
			left: 0;
			width: 750rpx;
			padding: 30rpx;
			padding-bottom: 120rpx;
			height: 120rpx;
			background: #ffffff;
			display: flex;
			justify-content: center;
		
			.bnt {
				margin-left: 30rpx;
				color: #ffffff;
				width: 306rpx;
				height: 88rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 10rpx;
				background: #4D8987;
			}
		}
	}
</style>